package binary_search.leetcode_374;

public class GuessNumber extends guess{
    public int guessNumber(int n) {
        //[1...n]
        int left = 1;
        int right = n;
        while(left <= right){
            int mid =left + (right - left) / 2;
            if(guess(mid) == 0){
                return mid;
            }else if(guess(mid) == -1){
                right = mid - 1;
            }else{
                left = mid + 1;
            }
        }
        return -1;
    }
}
